package config;

import org.apache.commons.dbcp.BasicDataSource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.web.context.ContextLoaderListener;

/**
 * 监听器配置
 */
@Configuration
public class SpringConfiguration {
    @Bean
    public ContextLoaderListener contextLoaderListener(){
        return new ContextLoaderListener();
    }

    @Bean
    public DataSourceTransactionManager transactionManager(BasicDataSource dataSource) {
        DataSourceTransactionManager transactionManager = new
                DataSourceTransactionManager();
        transactionManager.setDataSource(dataSource);
        return transactionManager;
    }
}
